home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / WarpQuake / Src / amiga_ppc_d_scan.s < prev    next >
Text File  |  2000-05-22  |  5KB  |  202 lines

  1. # Copyright (C) 2000 Peter McGavin.
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  11. #
  12. # See the GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17.  
  18.         .section    ".rodata"
  19.         .align 2
  20. .LC6:
  21.         .long 0x41000000
  22.         .align 3
  23. .LC7:
  24.         .long 0x43300000
  25.         .long 0x80000000
  26.         .align 2
  27. .LC8:
  28.         .long 0x47800000
  29.         .align 2
  30. .reciprocals:
  31.         .long 0x55555555    # 1/3
  32.         .long 0x40000000    # 1/4
  33.         .long 0x33333333    # 1/5
  34.         .long 0x2aaaaaab    # 1/6
  35.         .long 0x24924925    # 1/7
  36.  
  37. ########################################################################
  38.         .section    ".rodata"
  39.         .align 2
  40. .LC9:
  41.         .long 0x4f000000
  42.         .align 3
  43. .LC10:
  44.         .long 0x43300000
  45.         .long 0x80000000
  46.         .align 3
  47. .LC11:
  48.         .long 0x41e00000
  49.         .long 0x0
  50.  
  51.         .section    ".text"
  52.         .align    2
  53.         .globl    D_DrawZSpans
  54.         .type    D_DrawZSpans,@function
  55.         .globl    _D_DrawZSpans
  56.         .type    _D_DrawZSpans,@function
  57.  
  58.         .extern    d_pzbuffer
  59.         .extern    d_zwidth
  60.         .extern d_zistepu
  61.         .extern d_zistepv
  62.         .extern d_ziorigin
  63.  
  64. D_DrawZSpans:
  65. _D_DrawZSpans:
  66.         stwu    r1,-48(r1)
  67.         stw    r26,24(r1)
  68.         stw    r27,28(r1)
  69.         stw    r28,32(r1)
  70.         stw    r29,36(r1)
  71.         stw    r30,40(r1)
  72.         stw    r31,44(r1)
  73.  
  74. #    izistep = (int)(d_zistepu * 0x8000 * 0x10000);
  75.  
  76.         lis    r11,.LC9@ha
  77.         lis    r9,d_zistepu@ha
  78.         la    r11,.LC9@l(r11)
  79.         lfs    f0,d_zistepu@l(r9)
  80.         lis    r26,d_pzbuffer@ha
  81.         lfs    f12,0(r11)
  82.         lis    r9,.LC10@ha
  83.         lis    r27,d_zwidth@ha
  84.         la    r9,.LC10@l(r9)
  85.         lfd    f8,0(r9)
  86.         lis    r31,0x4330
  87.         lis    r28,d_ziorigin@ha
  88.         fmuls    f0,f0,f12
  89.         lis    r9,.LC11@ha
  90.         lis    r29,d_zistepv@ha
  91.         la    r9,.LC11@l(r9)
  92.         lis    r30,d_zistepu@ha
  93.         lfd    f7,0(r9)
  94.         fctiwz    f13,f0
  95.         stfd    f13,16(r1)
  96.         lwz    r5,20(r1)
  97.  
  98.         lfs    f6,d_ziorigin@l(r28)
  99.         lfs    f10,d_zistepv@l(r29)
  100.         lfs    f9,d_zistepu@l(r30)
  101.         lwz    r27,d_zwidth@l(r27)
  102.         lwz    r26,d_pzbuffer@l(r26)
  103. .L171:
  104.  
  105. #  pdest = d_pzbuffer + (d_zwidth * pspan->v) + pspan->u;
  106. #  count = pspan->count;
  107. #  du = (float)pspan->u;
  108. #  dv = (float)pspan->v;
  109. #  zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
  110. #  izi = (int)(zi * 0x8000 * 0x10000);
  111.  
  112.         lwz    r10,0(r3)    # r10 = pspan->u
  113.         lwz    r8,4(r3)    # r8 = pspan->v
  114.         xoris    r11,r10,0x8000    # r11 = pspan->u ^ 0x8000
  115.         xoris    r9,r8,0x8000    # r9 = pspan->v ^ 0x8000
  116.         mullw    r0,r27,r8    # r0 = d_zwidth * pspan->v
  117.         stw    r11,20(r1)
  118.         stw    r31,16(r1)    # 0x4330
  119.         lfd    f12,16(r1)
  120.         stw    r9,20(r1)
  121.         lfd    f13,16(r1)
  122.         fsub    f12,f12,f8    # f12 = (double)pspan->u
  123.         lwz    r4,8(r3)    # count = pspan->count
  124.         fsub    f13,f13,f8    # f13 = (double)pspan->v
  125.         add    r0,r0,r10    # r0 = d_zwidth * pspan->v + pspan->u
  126.         fmadds    f13,f13,f10,f6    # f13 = pspan->v * d_zistepv + d_ziorigin
  127.         add    r0,r0,r0    # r0 = 2*(d_zwidth * pspan->v + pspan->u)
  128.         fmadds    f12,f12,f9,f13    # zi = pspan->u * d_zistepu + f13
  129.         add    r6,r26,r0    # pdest = d_pzbuffer + r0
  130.         fmuls    f0,f12,f7    # f0 = zi * f7
  131.         andi.    r11,r6,2    # pdest & 2
  132.         fctiwz    f11,f0
  133.         stfd    f11,16(r1)
  134.         lwz    r8,20(r1)    # izi = (int)(zi * f7)
  135.  
  136. #  if ((long)pdest & 0x02) {
  137. #    *pdest++ = (short)(izi >> 16);
  138. #    izi += izistep;
  139. #    count--;
  140. #  }
  141.  
  142.         beq-    .L164        # branch if (((long)pdest & 2) == 0)
  143.         srawi    r10,r8,16    # r10 = izi >> 16
  144.         addi    r4,r4,-1    # count--
  145.         add    r8,r8,r5    # izi += izistep
  146.         addi    r6,r6,2        # pdest++
  147.         sthx    r10,r26,r0    # *pdest = r10
  148. .L164:
  149.  
  150. #  if ((doublecount = count >> 1) > 0) {
  151. #    do {
  152. #      ltemp = izi >> 16;
  153. #      izi += izistep;
  154. #      ltemp |= izi & 0xFFFF0000;
  155. #      izi += izistep;
  156. #      *(int *)pdest = ltemp;
  157. #      pdest += 2;
  158. #    } while (--doublecount > 0);
  159. #  }
  160.  
  161.         srawi.    r7,r4,1        # doublecount = count >> 1
  162.         ble-    .L165
  163.         mtctr    r7        # MCIU
  164.         add    r10,r8,r5    # SCIU1     izi2 = izi + izistep
  165.         slwi    r11,r5,1    # SCIU2     izistep2 = izistep << 1
  166. .loop2:
  167.         srawi    r9,r8,16    # SCIU1 1   ltemp = izi >> 16
  168.         clrrwi    r0,r10,16    # SCIU2 1   r0 = izi2 & 0xffff0000
  169.         or    r9,r9,r0    # SCIU1 2   ltemp |= r0
  170.         add    r8,r8,r11    # SCIU2 2   izi += izistep2
  171.         stw    r9,0(r6)    # LSU   3-5 *(int *)pdest = ltemp
  172.         add    r10,r10,r11    # SCIU1 3   izi2 += izistep2
  173.         addi    r6,r6,4        # SCIU2 3   pdest += 2
  174.         bdnz+    .loop2        # BPU   3
  175. .L165:
  176.  
  177. #  if (count & 1)
  178. #    *pdest = (short)(izi >> 16);
  179.  
  180.         andi.    r0,r4,1        # (count & 1)
  181.         beq-    .L163
  182.         srawi    r0,r8,16    # r0 = izi >> 16
  183.         sth    r0,0(r6)    # *pdest = r0
  184. .L163:
  185.  
  186. #} while ((pspan = pspan->pnext) != NULL);
  187.  
  188.         lwz    r3,12(r3)    # pspan = pspan->next
  189.         cmpwi    cr0,r3,0
  190.         bne+    .L171
  191.  
  192.         lwz    r26,24(r1)
  193.         lwz    r27,28(r1)
  194.         lwz    r28,32(r1)
  195.         lwz    r29,36(r1)
  196.         lwz    r30,40(r1)
  197.         lwz    r31,44(r1)
  198.         la    r1,48(r1)
  199.         blr
  200. .Lfe5:
  201.         .size    D_DrawZSpans,.Lfe5-D_DrawZSpans
  202.